package com.firefly.service.command.cms;

import com.firefly.dao.assembler.cms.AdAssembler;
import com.firefly.dao.dto.cms.AdDto;
import com.firefly.service.repository.cms.AdRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @description: 广告
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2022/12/18
 **/
@Service
public class AdCommand {
    private final AdAssembler adAssembler;
    private final AdRepository adRepository;

    @Autowired
    public AdCommand(AdAssembler adAssembler, AdRepository adRepository) {
        this.adAssembler = adAssembler;
        this.adRepository = adRepository;
    }

    public Boolean create(AdDto request) {
        return adRepository.create(adAssembler.getPo(request));
    }

    public Boolean update(AdDto request) {
        return adRepository.update(adAssembler.getPo(request));
    }

    public Boolean updateSort(int id, int sort) {
        return adRepository.updateSortById(id, sort);
    }

    public Boolean removeByIds(List<Integer> ids) {
        return adRepository.updateDelFlagById(ids);
    }
}
